package com.tianhui.consignortwofei.mvp.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import com.tianhui.consignortwofei.R;
import com.tianhui.consignortwofei.mvp.model.enty.DriverInfo;

import org.yczbj.ycrefreshviewlib.adapter.RecyclerArrayAdapter;
import org.yczbj.ycrefreshviewlib.holder.BaseViewHolder;

/**
 * @author fgs
 * @date 2021/8/10
 * @description
 */
public class DriverDetailAdapter extends RecyclerArrayAdapter<DriverInfo> {

    public DriverDetailAdapter(Context context) {
        super(context);
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new DriverDetailViewHolder(parent, R.layout.item_driver_detail);
    }

    private class DriverDetailViewHolder extends BaseViewHolder<DriverInfo> {

        private final TextView driverNameTextView;
        private final TextView driverPhoneTextView;
        private final TextView vehicleNumberTextView;

        public DriverDetailViewHolder(ViewGroup parent, int res) {
            super(parent, res);
            driverNameTextView = getView(R.id.item_driver_detail_driverNameTextView);
            driverPhoneTextView = getView(R.id.item_driver_detail_driverPhoneTextView);
            vehicleNumberTextView = getView(R.id.item_driver_detail_vehicleNumberTextView);
        }

        @Override
        public void setData(DriverInfo data) {
            super.setData(data);
            driverNameTextView.setText(data.drivername);
            driverPhoneTextView.setText(data.drivertel);
            vehicleNumberTextView.setText(data.defaultvehiclenum);
        }
    }
}
